<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类型转换</title>
</head>
<body>
    <!-- 其他类型墙砖string 转换结果是value的字面量 -->
    <!-- <script>
        var value = 123;
        value = true
        value = null
        value = undefined

        var str = String(value)
        console.log(value,str);
    </script> -->

    <!-- 其他类型强制转换number -->
    <!-- <script>
        var value = "123"//123
        value = true //1
        value = false //0
        value = null //0
        value = undefined //转换结果 NaN (not a number)

        //只要字符串的字面量不是一个正常的数值 则转换结果为NaN
        value = "令妹"//NaN
        value = "618令妹"//NaN
        value = "令妹666"//NaN

        var num = Number(value)
        console.log(value,num);
    </script> -->

    <!-- 其他类型转为布尔 0 NaN "" null undefined 转布尔得false 余众皆true -->
    <script>
        // 常规的字符串和number转布尔皆为true
        var value = "令妹666"
        value = 123

        // // null/undefined转布尔得false
        value = null
        value = undefined

        // // ”非常规“字符串/number转布尔得false
        value = ""
        value = 0

        var boo = Boolean(value)
        console.log(value,boo);
    </script>
</body>
</html>